﻿using SIG.Model.Identity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SIG.Data.Extensions
{
    public static class UserLinqQuery
    {
        public static IQueryable<User> SetFilters(this IQueryable<User> users, string username, DateTime? startDate, DateTime? endDate)
        {
            if (!string.IsNullOrEmpty(username))
            {
                users = users.Where(c => c.UserName == username);
            }

            if (startDate != null)
            {
                users = users.Where(l => l.CreateDate >= startDate);
            }

            if (endDate != null)
            {
                users = users.Where(l => l.CreateDate <= endDate);
            }           

            return users;
        }
    }
}
